package com.finger.demo.excel;

import com.alibaba.excel.EasyExcel;

import java.util.ArrayList;
import java.util.List;

public class ExcelDemo {

    public static void main(String[] args) {
          // 写操作
//        String fileName = "X:\\student.xlsx";

//        EasyExcel.write(fileName,ExcelData.class).sheet("学生信息").doWrite(getData());

        String fileName = "X:\\student.xlsx";

        EasyExcel.read(fileName,ExcelData.class,new ExcelListener()).sheet().doRead();

        List list = ExcelListener.getList();

        System.out.println(list.toString());


    }

    public static List<ExcelData> getData(){
        ArrayList<ExcelData> objects = new ArrayList<>();
        for (int i = 0; i < 10; i++) {
            ExcelData excelData = new ExcelData();
            excelData.setSid(i);
            excelData.setSname("chao"+i);
            objects.add(excelData);
        }
        return objects;
    }
}
